﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ConfigService
{
    public class EnvVarConfigService : IConfigService
    {
        public string FileName { get; set; }

        private Dictionary<string, string> readAllFileValue = new Dictionary<string, string>();
        public bool AddOREditKeyValue(string key, string val)
        {
            readAllFileValue[key] = val;
            return true;
        }

        public bool ExistFileName()
        {
            return true;
        }

        public string GetValue(string name)
        {
            return Environment.GetEnvironmentVariable(name);
        }

        public bool SaveAll()
        {
            foreach (var kvp in this.readAllFileValue)
            {
                // Environment.SetEnvironmentVariable(kvp.Key, kvp.Value);
                Console.WriteLine($"设置环境变量  {kvp.Key}：{kvp.Value}");
            }
            return true;
        }
    }
}
